//  Copyright (c) 2008  Yoong-ki Ahn & Youngjin Kim < mexif@googlegroups.com>
//  See the enclosed file COPYING for license information (MIT Licence).
//  If you did not receive this file,
//  see http://www.opensource.org/licenses/mit-license.php.

package mexif;

public class Jfif {
	byte		mVersionMajor, mVersionMinor;
	byte		mUnits;
	int			mXdensity, mYdensity;
	int			mXthunmnail, mYthumbnail;

//	typedef struct
//	{
//		unsigned char			Identifier[5];		// "JFIF\0"
//		unsigned char			VersionMajor;
//		unsigned char			VersionMinor;
//		unsigned char			Units;
//		mexif_uint16			Xdensity;
//		mexif_uint16			Ydensity;
//		unsigned char			Xthumbnail;
//		unsigned char			Ythumbnail;
//	} mexif_jfif_partial_t;

	
	public Jfif(byte[] data, int offset, int length) throws JpegException {
		// TODO Auto-generated constructor stub
		final int MIN_SIZE = 16;
		if( length < MIN_SIZE )
			return;
		
//		data must start with "JFIF"
		if( data.length >= 5 + offset && 
				data[offset] == 'J' && data[offset+1] == 'F' && data[offset+2] == 'I' &&
				data[offset+3] == 'F' && data[offset+4] == '\0' )
			throw new JpegException("Not a JFIF section");
	}

}
